package com.shg.web.ztest;


import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import com.shg.web.tools.MD5;

public class SpringTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		System.out.println("邮件发送成功.....");
	}

	@Test
	public  void sendTestMail() {
		try {
			
			JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
			// 设定mail server   shg_fcy@sina.com  http://www.cnblogs.com/xuqiang/archive/2010/11/17/1953397.html
//			senderImpl.setHost("smtp.qq.com");
//			senderImpl.setUsername("120003114@QQ.com");
//			senderImpl.setPassword("cmx15994417552");
			
			senderImpl.setHost("smtp.sina.com");
			senderImpl.setUsername("shg_fcy@sina.com");
			senderImpl.setPassword("131498");
			senderImpl.getJavaMailProperties().setProperty("mail.smtp.auth", "true");

			// 建立邮件消息
			SimpleMailMessage mailMessage = new SimpleMailMessage();
			// 设置收件人，寄件人
			// String[] array = new String[] {"xxx@163.com ","xxx@sohu.com "};
			// mailMessage.setTo(array);ehlo auth
			mailMessage.setTo("120003114@QQ.com");
			mailMessage.setFrom("shg_fcy@sina.com");
			mailMessage.setSubject("测试邮件！");
			mailMessage.setText("测试我的简单邮件发送机制！！");

			// 发送邮件
			senderImpl.send(mailMessage);

			System.out.println("邮件发送成功.....");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	@Test
	public void testone(){
		System.out.println(MD5.MD5Encode("131498"));
	}
}
